<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<!DOCTYPE html PUBLIC "-//W3C//Ddiv HTML 4.01 divansitional//EN" "http://www.w3.org/div/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-81">
  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>
  <link href="${ctx.resource}/css/goals.css" rel="stylesheet">
  <title>人马君</title>
</head>
<body>
  <body>
    <div class="page-group">
      <div class="page page-current">
        <header class="bar bar-nav fs-header-small">
          <a href="${ctx.host}/rounds/${courseRoundId}/weekly-plan?week=${week}<c:choose><c:when test='${not empty scheduleId}'>&scheduleId=${scheduleId}</c:when><c:otherwise><c:if test='${not empty back}'>&back=${back}</c:if></c:otherwise></c:choose>" class="icon icon-left pull-left"></a>
          <h1 class="title" style="font-weight: bold;">第${week}周计划-饮食</h1>
        </header>
        
        <div class="bar bar-footer">
          <button class="button button-fill button-save" style="position: absolute; top: 0; left: 0; border-radius: 0;background: #fedc32; font-size: 1rem; font-weight: bold; color: #333; min-height: 2.2rem; width: 100%;">保存</button>
        </div>
        <div class="content">
          <form method="post" action="${ctx.host}/rounds/${courseRoundId}/weekly-plan/${batchId}/edit-dietary">
            <input type="hidden" name="_method" value="PATCH">
          
            <div class="diet-wrap" style="padding-bottom: 1rem;">
              <div class="card" style="margin: .5rem 0;">
                <div class="card-header">早餐</div>
                <div class="card-content">
                  <div class="card-content-inner">
                    <div class="action-header">
                      <label class="action-title">早餐 / <small>${dietary.breakfastTemplate.name}</small></label>
                      <a href="javascript:void(0);" class="pull-right diet-modify" data-type="breakfast" 
                         data-template="${not empty dietary.breakfastTemplate ? dietary.breakfastTemplate.id : ''}"
                         style="display:${not empty dietary.breakfastTemplate ? '' : 'none'}">修改</a>
                      <input type="hidden" name="breakfastTemplateId" value="${dietary.breakfastTemplate.id}">
                    </div>
                    <div class="action-content">
                      <c:choose>
                        <c:when test="${empty dietary.breakfastTemplate}">
                          <a href="javascript:void(0);" class="add-diet-btn set-meal" data-type="breakfast"></a>
                          <div class="intro" style="display:none;">
                            <textarea name="breakfastDescription" class="diet-description" placeholder="饮食描述"></textarea>
                          </div>
                        </c:when>
                        <c:otherwise>
                          <div class="intro">
                            <textarea name="breakfastDescription" class="diet-description" placeholder="饮食描述">${dietary.breakfastDescription}</textarea>
                          </div>
                        </c:otherwise>
                      </c:choose>
                    </div>
                  </div>
                  <div class="card-content-inner">
                    <div class="action-header">
                      <label class="action-title">早餐加餐 / <small>${dietary.breakfastSnackTemplate.name}</small></label>
                      <a href="javascript:void(0);" class="pull-right diet-modify" data-type="snack" 
                      data-template="${not empty dietary.breakfastSnackTemplate ? dietary.breakfastSnackTemplate.id : ''}"
                      style="display:${not empty dietary.breakfastSnackTemplate ? '' : 'none'}">修改</a>
                      <input type="hidden" name="breakfastSnackTemplateId" value="${dietary.breakfastSnackTemplate.id}">
                    </div>
                    <div class="action-content">
                      <c:choose>
                        <c:when test="${empty dietary.breakfastSnackTemplate}">
                          <a href="javascript:void(0);" data-type="snack" data-snack="breakfast" class="add-diet-btn set-meal"></a>
                          <div class="intro" style="display:none;">
                            <textarea name="breakfastSnackDescription" class="diet-description" placeholder="饮食描述"></textarea>
                          </div>
                        </c:when>
                        <c:otherwise>
                          <div class="intro">
                            <textarea name="breakfastSnackDescription" class="diet-description" placeholder="饮食描述">${dietary.breakfastSnackDescription}</textarea>
                          </div>
                        </c:otherwise>
                      </c:choose>
                    </div> 
                  </div>
                </div>
              </div>
              <div class="card" style="margin: .5rem 0;">
                <div class="card-header">午餐</div>
                <div class="card-content">
                  <div class="card-content-inner">
                    <div class="action-header">
                      <label class="action-title">午餐 / <small>${dietary.lunchTemplate.name}</small></label>
                      <a href="javascript:void(0);" class="pull-right diet-modify" data-type="lunch" 
                      data-template="${not empty dietary.lunchTemplate ? dietary.lunchTemplate.id : ''}"
                      style="display:${not empty dietary.lunchTemplate ? '' : 'none'}">修改</a>
                      <input type="hidden" name="lunchTemplateId" value="${dietary.lunchTemplate.id}">
                    </div>
                    <div class="action-content">
                      <c:choose>
                        <c:when test="${empty dietary.lunchTemplate}">
                          <a href="javascript:void(0);" data-type="lunch" class="add-diet-btn set-meal"></a>
                          <div class="intro" style="display:none;">
                            <textarea name="lunchDescription" class="diet-description" placeholder="饮食描述"></textarea>
                          </div>
                        </c:when>
                        <c:otherwise>
                          <div class="intro">
                            <textarea name="lunchDescription" class="diet-description" placeholder="饮食描述">${dietary.lunchDescription}</textarea>
                          </div>
                        </c:otherwise>
                      </c:choose>
                    </div>
                  </div>
                  <div class="card-content-inner">
                    <div class="action-header">
                      <label class="action-title">午餐加餐 / <small>${dietary.lunchSnackTemplate.name}</small></label>
                      <a href="javascript:void(0);" class="pull-right diet-modify" data-type="snack" 
                      data-template="${not empty dietary.lunchSnackTemplate ? dietary.lunchSnackTemplate.id : ''}"
                      style="display:${not empty dietary.lunchSnackTemplate ? '' : 'none'}" >修改</a>
                      <input type="hidden" name="lunchSnackTemplateId" value="${dietary.lunchSnackTemplate.id}">
                    </div>
                    <div class="action-content">
                      <c:choose>
                        <c:when test="${empty dietary.lunchSnackTemplate}">
                          <a href="javascript:void(0);" data-type="snack" data-snack="lunch" class="add-diet-btn set-meal"></a>
                          <div class="intro" style="display:none;">
                            <textarea name="lunchSnackDescription" class="diet-description" placeholder="饮食描述"></textarea>
                          </div>
                        </c:when>
                        <c:otherwise>
                          <div class="intro">
                            <textarea name="lunchSnackDescription" class="diet-description" placeholder="饮食描述">${dietary.lunchSnackDescription}</textarea>
                          </div>
                        </c:otherwise>
                      </c:choose>
                    </div> 
                  </div>
                </div>
              </div>
              <div class="card" style="margin: .5rem 0;">
                <div class="card-header">晚餐</div>
                <div class="card-content">
                  <div class="card-content-inner">
                    <div class="action-header">
                      <label class="action-title">晚餐 / <small>${dietary.dinnerTemplate.name}</small></label>
                      <a href="javascript:void(0);" class="pull-right diet-modify" data-type="dinner" 
                        data-template="${not empty dietary.dinnerTemplate ? dietary.dinnerTemplate.id : ''}"
                        style="display:${not empty dietary.dinnerTemplate ? '' : 'none'}">修改</a>
                      <input type="hidden" name="dinnerTemplateId" value="${dietary.dinnerTemplate.id}">
                    </div>
                    <div class="action-content">
                      <c:choose>
                        <c:when test="${empty dietary.dinnerTemplate}">
                          <a href="javascript:void(0);" data-type="dinner" class="add-diet-btn set-meal"></a>
                          <div class="intro" style="display:none;">
                            <textarea name="dinnerDescription" class="diet-description" placeholder="饮食描述"></textarea>
                          </div>
                        </c:when>
                        <c:otherwise>
                          <div class="intro">
                            <textarea name="dinnerDescription" class="diet-description" placeholder="饮食描述">${dietary.dinnerDescription}</textarea>
                          </div>
                        </c:otherwise>
                      </c:choose>
                    </div>
                  </div>
                  <div class="card-content-inner">
                    <div class="action-header">
                      <label class="action-title">晚餐加餐 / <small>${dietary.dinnerSnackTemplate.name}</small></label>
                      <a href="javascript:void(0);" class="pull-right diet-modify" data-type="snack" 
                      data-template="${not empty dietary.dinnerSnackTemplate ? dietary.dinnerSnackTemplate.id : ''}"
                      style="display:${not empty dietary.dinnerSnackTemplate ? '' : 'none'}">修改</a>
                      <input type="hidden" name="dinnerSnackTemplateId" value="${dietary.dinnerSnackTemplate.id}">
                    </div>
                    <div class="action-content">
                      <c:choose>
                        <c:when test="${empty dietary.dinnerSnackTemplate}">
                          <a href="javascript:void(0);" data-type="snack" data-snack="dinner" class="add-diet-btn set-meal"></a>
                          <div class="intro" style="display:none;">
                            <textarea name="dinnerSnackDescription" class="diet-description" placeholder="饮食描述"></textarea>
                          </div>
                        </c:when>
                        <c:otherwise>
                          <div class="intro">
                            <textarea name="dinnerSnackDescription" class="diet-description" placeholder="饮食描述">${dietary.dinnerSnackDescription}</textarea>
                          </div>
                        </c:otherwise>
                      </c:choose>
                    </div> 
                  </div>
                </div>
              </div>
              
              <div class="card" style="margin: .5rem 0;">
                <div class="card-header">饮水量</div>
                <div class="card-content">
                  <div class="card-content-inner" style="padding-top: 0rem;">
                    <div class="action-content">
                      <div class="intro">
                        <textarea name="waterIntake" class="diet-description" placeholder="请输入饮水量">${dietary.waterIntake}</textarea>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              
              <div class="card" style="margin: .5rem 0;">
                <div class="card-header">备注</div>
                <div class="card-content">
                  <div class="card-content-inner" style="padding-top: 0rem;">
                    <div class="action-content">
                      <div class="intro">
                        <textarea name="remark" class="diet-description" placeholder="请输入备注">${dietary.remark}</textarea>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            
            <button type="submit" style="display: none;"></button>
          </form>
          
          
          
          <!-- <div class="text-center" style="background: #fff190; padding: 1rem 0;">营养元素</div>
          <div class="content-block target-course weekly-plan" style="padding: 0; margin: 0">
            <div class="basic-item">
              <div class="item flex-shrink">碳水化合物</div>
              <div class="item">
                <p>来源：<span>粗粮，根茎类蔬菜</span></p>
                <p>GI值：<span>高</span></p>
              </div>
            </div>
            <div class="basic-item">
              <div class="item flex-shrink">蛋白质</div>
              <div class="item"><p>来源：<span>豆类，肉类(瘦肉)</span></p></div>
            </div>
            <div class="basic-item">
              <div class="item flex-shrink">维生素及纤维素</div>
              <div class="item"><p>来源：<span>叶子蔬菜，水果</span></p></div>
            </div>
          </div> -->
        </div>
      </div>
    </div>
  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource type="script" root="${ctx.resource}/build" src="js/page/courseware/weekly-plan-dietary-edit.js" />
  <script type="text/javascript">
    require(['page/courseware/weekly-plan-dietary-edit'], function(page) {
      page.init({
          'roundId': '${courseRoundId}',
          'batchId': '${batchId}',
          'week': '${week}',
          'breakfasts':JSON.parse('${breakfasts}'),
          'lunchs': JSON.parse('${lunchs}'),
          'dinners': JSON.parse('${dinners}'),
          'snacks': JSON.parse('${snacks}')
      })
    })
  </script>
  
  </body>
</html>
